#include <iostream>
#include <set>
#include <cstring>
using namespace std;

int tree[1001][2] = {0};
int gold[51][51] = {0};
int n, L, S, result = 0;
set<string>isTree;

int main() {
	cin >> n >> L >> S;
	S++; // 藏宝图大小为S + 1
	for (int i = 0; i < n; i++) {
		cin >> tree[i][0] >> tree[i][1];
		isTree.insert(to_string(tree[i][0]) + "_" + to_string(tree[i][1])); // 空间换时间，O(1)的时间内找到某坐标是否有树
	}
	int temp, g = 0, tree_num = 0;
	for (int i = S - 1; i >= 0; i--) { // 逆序输入
		for (int j = 0; j < S; j++) {
			cin >> temp;
			if (temp) {
				gold[i][j] = 1;
				tree_num++;
			}
		}
	}

	int big_tree_num;
	for (int i = 0; i < n; i++) { // 对于每一颗树
		int x = tree[i][0], y = tree[i][1], success = 1, big_x, big_y, big_tree_num = 0;
		for (int l = 0; l < n; l++) { // 求当前点S长宽小地图内树的总数
			if (tree[l][0] >= x && tree[l][0] <= x + S - 1 && tree[l][1] >= y && tree[l][1] <= y + S - 1) {
				big_tree_num++;
			}
		}
		if (tree_num != big_tree_num) { // 树的数量对不上直接下一棵树（可以省略极大的时间！！！100分关键代码！）
			continue;
		}
		for (int j = 0; j < S && success; j++) { // 遍历子藏宝图中每一颗树是否对应大地图
			for (int k = 0; k < S; k++) {
				big_x = j + x;
				big_y = k + y;
				// 越界或者 树不对应
				if (big_x > L || big_y > L || isTree.count(to_string(big_x) + "_" + to_string(big_y)) != gold[j][k]) {
					success = 0; // 外层循环里的j也会停止
					break;
				}
			}
		}
		if (success) {
			result++;
		}
	}
	cout << result;
	return 0;
}